package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class ReflectDemo3 {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Class cls = Person.class;

        Constructor con = cls.getConstructor(String.class);
        Object obj = con.newInstance("崇宫澪");
        System.out.println(obj);

        Constructor con2 = cls.getConstructor(String.class, int.class);
        Object obj2 = con2.newInstance("张三", 24);
        System.out.println(obj2);



    }
}
